package pl.matt.media.strategy.impl;

import java.io.File;
import java.text.DecimalFormat;

import pl.matt.media.strategy.FrameNamingStrategy;

/**
 * @author mateusz
 * 
 */
public class DecimalFormatFrameNamingStrategy implements FrameNamingStrategy {

	private java.text.Format format = new DecimalFormat("0000000000");
	private String directoryPath = "/tmp";
	private long divisor = 10000000;
	private String extension = ".jpg";

	@Override
	public String getName(Long timestamp) {
		String fileName = format.format(Long.valueOf(timestamp / divisor));
		return directoryPath + File.separator + fileName + extension;
	}

	/**
	 * @param directoryPath
	 */
	public void setDirectoryPath(String directoryPath) {
		this.directoryPath = directoryPath;
	}

	/**
	 * @param divisor
	 */
	public void setDivisor(long divisor) {
		this.divisor = divisor;
	}

	/**
	 * @param extension
	 */
	public void setExtension(String extension) {
		this.extension = extension;
	}

	/**
	 * @param pattern
	 */
	public void setPattern(String pattern) {
		format = new DecimalFormat(pattern);
	}

}
